<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- JSTL标签库是一个JSP标签的集合，封装了许多jsp应用程序通用的核心功能-->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!-- JSTL格式化标签 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css"/>
		<script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
		<style>
			.layui-form{
				margin-top: 30px;
				margin-left: 30px;
			}
		</style>

</head>
<body>
	<form class="layui-form" <%-- action="" --%>>
	  <div class="layui-form-item">
	    <label class="layui-form-label">学院ID：</label>
	    <div class="layui-input-inline">
	      <input id="i1" type="text" name="id" class="layui-input" value="">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">学院名称：</label>
	    <div class="layui-input-inline">
	      <input id="i2" type="text" name="cName" class="layui-input" value="">
	    </div>
	  </div>

	</form>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" style="width: 100px;" onclick="add()">添加</button>
	    </div>
	  </div>
	<script>
	//提交学院信息
 	function add(){
		var params = $("form").serialize();
		console.info(params);
		$.ajax({
			url: "c",
			data: params+"&m=addOneCollege",
			type: "post",
			success: function(code){
				if(code == '1'){
					alert("添加成功");
				} else {	
					alert("添加失败");
				}
				//延迟关闭
				setTimeout(closeLayer(), 500);
			}
		});
	}
	
	function closeLayer(){
		//关闭弹出层
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
		//刷新父页面
		window.parent.location.reload();
	} 
	</script>
</body>
</html>